package com.globallogic.webapp;

import static org.junit.Assert.*;

import java.util.Map;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.globallogic.webapp.javaclasses.Users;

public class UsersTest {
	Users users = new Users();

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test()
	public void addUser() {
		users.addUser("login", "pass");
		assertTrue(users.getUsers().size() > 0);
	}

	@Test
	public void returnNotEmptry_Md5() {
		String inputPass = "blalals";
		String md5Str = users.md5(inputPass);
		assertFalse(md5Str.isEmpty());
	}

	@Test(expected = NullPointerException.class)
	public void NullPass_Md5() {
		String inputPass = null;
		users.md5(inputPass);
	}

	@Test
	public void equalsSamePass_Md5() {
		String inputPass = "blalals";
		String md5StrExpected = users.md5(inputPass);
		String md5StrActual = users.md5(inputPass);
		assertEquals(md5StrExpected, md5StrActual);
	}

	@Test
	public void getUsersNotNull() {
		Map<String, String> usersTest = users.getUsers();
		assertNotNull(usersTest);
	}

	@Test
	public void getUsersAfterAdding() {
		users.addUser("login", "pass");
		Map<String, String> usersTest = users.getUsers();
		assertFalse(usersTest.isEmpty());
	}
}
